<!--
 * @Description: 三角形
 * @Author: rendc
 * @Date: 2021-09-08 14:25:57
 * @LastEditors: rendc
 * @LastEditTime: 2021-09-08 15:22:40
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>三角形</title>
  <style>
    #app {
      width: 10px;
      height: 10px;
      border: 100px solid transparent;
      border-top: 100px solid #666;
      border-left: 100px solid yellow;
      border-right: 100px solid pink;
      border-bottom: 100px solid #999;
    }
  </style>
</head>

<body>
  <div id="app">

  </div>
</body>
<script>
  // function count(str, char) {
  //   var res = 0;
  //   for (let i = 0; i < str.length; i++) {
  //     if (str[i] == char) res++;
  //   }
  //   return res;
  // }
  // 正则表达式
  // function count(str, char) {
  //   var p = new RegExp(char, "gm");
  //   var res = str.match(p);
  //   return res.length;
  // }

  // console.log(this.count("hello", "l"));
  function mout(arr) {
    if (!Array.isArray(arr)) return arr;
    var brr = [];
    for (var i in arr) {
      var item = arr[i];
      brr = brr.concat(mout(item));
    }
    return brr;
  }
  var arr = [
    [1, 2, 3, [4, 5, 6, [7, 8]]],
    [9, 10],
    [11, 12, [13]], 5
  ];
  console.log(mout(arr));
</script>

</html>